package com.carl.controller;

import com.carl.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

@Controller
public class LogController {

    @Autowired
    private MessageService messageService;

    @RequestMapping("/")
    public String index(HttpServletRequest request){

        System.out.println("%%% loginController :  index ");
        return "index";
    }

    @RequestMapping("/login")
    public String login(HttpServletRequest request){
        String message = messageService.getMessage();
        System.out.println("%%% loginController : " + message);
        request.setAttribute("data","$$ this is your data &&&");
        return "login";
    }

    @RequestMapping("/register")
    public String registerSuccess(String username , HttpServletRequest request){
        System.out.println(" username : " + username);
        String pass = request.getParameter("password");

        request.setAttribute("username", username);
        request.setAttribute("password", pass);

        return "login";
    }


}
